<?php
session_start();
//print_r($_SESSION);
function Replace($str)
{
	if(is_null($str)) return $str;

	$word = array("<" => "&lt;", ">" => "&gt;", "'" => "&quot;", '"' => "&quot;");
	return strtr($str, $word);
}

//获取客户端的IP
function ip()
{
	if(getenv('HTTP_CLIENT_IP') && strcasecmp(getenv('HTTP_CLIENT_IP'), 'unknown')) 
	{
		$onlineip = getenv('HTTP_CLIENT_IP');
	}
	elseif(getenv('HTTP_X_FORWARDED_FOR') && strcasecmp(getenv('HTTP_X_FORWARDED_FOR'), 'unknown'))
	{
		$onlineip = getenv('HTTP_X_FORWARDED_FOR');
	}
	elseif(getenv('REMOTE_ADDR') && strcasecmp(getenv('REMOTE_ADDR'), 'unknown')) 
	{
		$onlineip = getenv('REMOTE_ADDR');
	} 
	elseif(isset($_SERVER['REMOTE_ADDR']) && $_SERVER['REMOTE_ADDR'] && strcasecmp($_SERVER['REMOTE_ADDR'], 'unknown')) 
	{
		$onlineip = $_SERVER['REMOTE_ADDR'];
	}
	$onlineip = preg_replace("/^([\d\.]+).*/", "\\1", $onlineip);
	return $onlineip;
}

?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>iCittys 會員中心 - 首頁</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link href="css/global.css" rel="stylesheet" type="text/css" />
<style type="text/css">
.main{
width:780px;
margin:0 auto;
}
</style>

</head>
<body>

<!-- 头部 -->
<div class="top">
	<div class="l">
		iCittys 會員中心
	</div>
	<div class="top_ad r">

	</div>
</div>

<!-- 导航 -->
<div class="menu">
	<span class="l"></span>
	<span class="r">
		<?php if(!is_array($_SESSION["user"])): ?>
		<a href="login.html">登入</a>
		<a href="reg.html">註冊</a>
		<?php else: ?>
		用戶名: <?php echo $_SESSION["user"]["username"];?>&nbsp;&nbsp;&nbsp;註冊時間: <?php echo $_SESSION["user"]["time"];?>&nbsp;&nbsp;&nbsp;<a href="javascript:void(0);" onclick="return disposal();">登出</a>&nbsp;&nbsp;
		<?php endif; ?>		
	</span>
</div>
<div class="main">
<ul>
	<li><a href="http://hot.icittys.com/desk/">炫桌布</a></li>
	<li><a href="http://bawbaw.icittys.com/nds/">NDS遊戲大全集</a></li>
</ul>
</div>
<div class="footer">
	<p>Powerd By APP-SSO</p>
	<p>技術支援：support@icittys.com </p>
</div>


<script type="text/javascript" src="http://hot.icittys.com/js/phprpc_client.js"></script>
  <script type="text/javascript">
  <!--
  	var APP_SSO_URL = 'http://app-sso.appspot.com/';
	var MAX_Retry = 100;
	var Retry_count = 0;
	var logout_ok_array = [];
	var http_response_code = {
		HTTP_RESPONSE_SIGN_NO:1,
		HTTP_RESPONSE_EMAIL_NO:2,
		HTTP_RESPONSE_EMAIL_OK:3,
		HTTP_RESPONSE_LOGIN_OK:4,
		HTTP_RESPONSE_DB_ERROR:5,
		HTTP_RESPONSE_LOGOUT_OK:6,
		HTTP_RESPONSE_DELETE_OK:7,
		HTTP_RESPONSE_DELETE_NO:8,
		HTTP_RESPONSE_UPDATE_OK:9,
		HTTP_RESPONSE_REGISTER_OK:10,
		HTTP_RESPONSE_VALIDATE_NO:11,
		HTTP_RESPONSE_VALIDATE_OK:12,
		HTTP_RESPONSE_USERNAME_NO:13,
		HTTP_RESPONSE_USERNAME_OK:14,
		HTTP_RESPONSE_PASSWORD_NO:15,
		HTTP_RESPONSE_EMAIL_EXISTS:16,
		HTTP_RESPONSE_VARIABLE_ERROR:17,
		HTTP_RESPONSE_USERNAME_EXISTS:18,
		HTTP_RESPONSE_EMAIL_NOT_EXISTS:19,
		HTTP_RESPONSE_USERNAME_NOT_EXISTS:20
	};

	function logout(url){
		var rpc = new PHPRPC_Client(url, ['logout']);
		rpc.logout(function(result){
			if(result == http_response_code.HTTP_RESPONSE_LOGOUT_OK)logout_ok_array[logout_ok_array.length] = result;
		});
	}
	function logout2_many_server(lists){
		sites_nums = lists.length;
		for(var i in lists){
			var url = lists[i];
			logout(url);
		}
		setTimeout(check_logout,100);
	}
	function check_logout(){
			if(logout_ok_array.length >= sites_nums){
				alert("登出成功");
				var myregexp = /\?done=([^&]+)/;
				var match = myregexp.exec(location.href);
				if (match != null) {
					window.location.href = decodeURIComponent(match[1]);
				} else {
					window.location.href = "http://hot.icittys.com/member/";
				}
			}else{
				Retry_count++;
				if(Retry_count<MAX_Retry){
					setTimeout(check_logout,100);
				}else{
					alert('登出超時，請重新登出');
				}
			}
	}
	function disposal()
	{
		var rpc = new PHPRPC_Client(APP_SSO_URL, ['logout']);
		rpc.logout(function(result){
			logout2_many_server(result);
		});

		return false;
	}
  //-->
  </script>
</body>
</html>